function SetCookie(name,val)
{
    if (val!='' && GetCookie(name,0))
    SetCookie(name,'');
    document.cookie=name+"="+val+"; path=/";
}

function GetCookie(name,def) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = def;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}
